<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <title>设备类型管理</title>
    <meta name="decorator" content="nblank"/>
</head>
<body>
<div class="content container">
    <h2 class="page-title">设备类型管理
        <small> 设备类型${not empty param.id?'修改':'添加'}</small>
    </h2>
    <section class="widget widget-tabs widget-table-overflow ">
        <header>
            <ul class="nav nav-tabs">
                <li><a href="${ctx}/biz/equipment/">设备类型列表</a></li>
                <li class="active"><a href="javascript:">设备类型${not empty param.id?'修改':'添加'}</a></li>
            </ul>
        </header>
        <div class="body tab-content">
            <form:form id="inputForm" modelAttribute="equipment" action="${ctx}/biz/equipment/save" method="post"
                       class="form-horizontal">
                <form:hidden path="id"/>
                <%--<sys:message content="${message}"/>--%>
                <div class="form-group">
                    <label class="control-label col-sm-4"><span class="help-inline"><span style="color:red;">*</span>名称:</span></label>
                    <div class="col-sm-4">
                        <form:input path="name" htmlEscape="false" maxlength="50"
                                    class="form-control input-transparent"/>
                    </div>
                </div>

                <div class="form-group">
                    <label class="control-label col-sm-4"><span class="help-inline"><span style="color:red;">*</span>标识:</span></label>
                    <div class="col-sm-4">
                        <form:input path="kid" htmlEscape="false" maxlength="50"
                                    class="form-control input-transparent"/>
                        <label id="kidScan" class="error" style="display: none;">标识已存在，请重填</label>
                    </div>
                </div>

                <div class="form-group">
                    <label class="control-label col-sm-4">描述:</label>
                    <div class="col-sm-4" style="margin-top:7px;">
                        <form:textarea path="describe" htmlEscape="false" class="form-control input-transparent"/>
                    </div>
                </div>
                <div class="form-actions">
                    <div class="text-align-center">
                        <input id="btnCancel" class="btn btn-default" type="button"
                               style="margin-left: -50px;min-width:100px;" value="返 回" onclick="history.go(-1)"/>
                        <input id="btnSubmit" class="btn btn-primary" style="margin-left:50px;min-width:100px;"
                               type="submit" value="保 存"/>&nbsp;
                    </div>
                </div>
            </form:form>
        </div>
    </section>
</div>
<script type="text/javascript">
    var $name = $("#name");
    var $kid = $("#kid");
    var $kidScan = $("#kidScan");
    var $inputForm = $("#inputForm");
    var $btnSubmit = $("#btnSubmit");

    $(function () {
        $name.focus();
        $name.focus(function () {
            $kidScan.css("display", "none");
        });
        $kid.focus(function () {
            $kidScan.css("display", "none");
        });
        $inputForm.validate({
            ignore: "",
            focusInvalid : true,
            rules: {
                name: "required",
                "kid":{
                    required:true
                }
            },
            messages: {
                "kid":{
                    required:"必填信息"
                }
            },
            invalidHandler: function () {
                $btnSubmit.attr("disabled", false);
            },
            errorPlacement: function(error, element) {
                error.appendTo(element.parent());
            },
            submitHandler: function (form) {
//                $(form).find(":submit").attr("disabled", true).attr("value", "提交中...");
                $(form).ajaxSubmit({
                    success: function (result) {
                        switch (result) {
                            case "success":
                                pxTrigDlg("${ctx}/biz/equipment");
                                break;
                            case "kidIsExist":
                                $kidScan.css("display", "block");
                                break;
                        }
                    }
                })
            }
        });
    });
</script>

</body>
</html>